package cn.client.di

import android.app.Application
import androidx.room.Room
import cn.client.data.localData.dao.UserDao
import cn.client.data.localData.AppDatabase
import cn.client.data.localData.dao.ChatMsgDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {

    @Singleton
    @Provides
    fun provideDatabase(application: Application): AppDatabase {
        return Room.databaseBuilder(
            application,
            AppDatabase::class.java,
            "app_database"
        ).build()
    }

    @Singleton
    @Provides
    fun provideUserDao(database: AppDatabase): UserDao {
        return database.userDao()
    }

    @Singleton
    @Provides
    fun provideChatMsgDao(database: AppDatabase): ChatMsgDao {
        return database.chatMsgDao()
    }

    // 如果还有其他Dao，继续添加提供方法

}